# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=brakeman
pkgver=v7.1.1.r5.g692411f7a
pkgrel=1
epoch=1
pkgdesc='A static analysis security vulnerability scanner for Ruby on Rails applications.'
groups=('blackarch' 'blackarch-code-audit' 'blackarch-exploitation'
        'blackarch-scanner' 'blackarch-webapp')
arch=('any')
url='https://brakemanscanner.org/'
license=('MIT')
depends=('ruby' 'ruby-bundler')
makedepends=('git')
source=("git+https://github.com/presidentbeef/$pkgname.git")
install="$pkgname.install"
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g'
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"
  install -dm 755 "$pkgdir/opt/$pkgname"

  install -Dm 644 MIT-LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  cp -a --no-preserve=ownership * "$pkgdir/opt/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
exec /opt/$pkgname/bin/$pkgname "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

